<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>打印金字塔</title>
    <style>
            a:link,a:visited{
                color: #222;text-decoration: none;}
           a:hover{color: #fd4913;}
       </style>
</head>
<body>
    <h2>打印金字塔</h2>
    <script>
        var level=prompt('请设置金字塔的层次');
        level=parseFloat(level)&&Number(level);
        if(isNaN(level)){
            alert('金字塔的层次必须是纯数字');
        }
        for(var i=1;i<=level;i++){
            var blank=level-i;
            for(var k=0;k<blank;k++){
                document.write('&nbsp;');
            }
            var star=i*2-1;
            for(var j=0;j<star;j++){
                document.write('*');
            }
            document.write('<br>');
        }
    </script>
    <p><a href="default.html">返回目录</a></p>
    <p><a href="第二章.html">返回第二章</a></p>
    <p><a href="九九乘法表.html">下一题</a></p>
    <p><a href="第三章.html">下一章</a></p>
</body>
</html>